/*
 * SpriteEngine.h
 *
 *  Created on: Mar 9, 2009
 *      Author: K
 */

#ifndef SPRITEENGINE_H_
#define SPRITEENGINE_H_

struct Sprite{
	Uint		key;
	int 		x_offset;
	int			y_offset;
	SDL_Surface *image;
};


class SpriteEngine{
	std::vector< Sprite* > *sprites; // vector for storing sprite structs
	std::vector< SDL_Surface* > *images;
	//std::vector< Entity<int>* > *drawable; // drawable entities

	// destructor iterator
	void delete_sprite(Sprite *_sprite){ delete _sprite; }

	public:
		SpriteEngine(){
			sprites = new std::vector< Sprite* >;
			images = new std::vector< SDL_Surface* >;
		}

		~SpriteEngine(){
			for(Uint i = 0; i < sprites->size(); i++){
				delete sprites->at(i);
			}
			delete sprites;
		}



		Uint add_image( std::string _file ){
			SDL_Surface *new_image = new SDL_Surface;
			new_image = SDL::load_image( _file );

			images->push_back( new_image );

			return images->size() - 1;
		}
		SDL_Surface * get_image( Uint key ){ return images->at(key); }


		void add_sprite( Sprite *_sprite ){ sprites->push_back( _sprite ); }
		std::vector< Sprite* > * get_sprites() const{ return sprites; }
		Sprite * get_sprite(Uint key) const{ return sprites->at(key); }
		SDL_Surface * get_sprite_surface(Uint key) const{ return sprites->at(key)->image; }
};

#endif /* SPRITEENGINE_H_ */
